package com.wanshi.dao;

import com.wanshi.entity.User;
import com.wanshi.utils.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class UserDao {


    //3 根据用户名查找用户
    public User findUserByName(String username){
        QueryRunner runner = new QueryRunner(JDBCUtil.getSource());

        String sql = "select  * from user where username=?";
        try {
            return runner.query(sql,new BeanHandler<>(User.class),username);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
